package com.ra.util;

import java.util.List;

import org.springframework.stereotype.Service;

import com.googlecode.cswish.annotation.Rest;

/**
 * 地址服务
 * 
 * @author colin
 * @date 2014年9月6日
 *
 */
@Service
public class AreaService {
	
	@Rest(simpleServiceName = "anonymity", type = "free")
	public List<Area> getChildArea(String areakey) {
		return AreaParser.getAreaInfo(areakey);
    }
	
	@Rest(simpleServiceName = "anonymity", type = "free")
	public String getAreaName(String areaCode) {
		return AreaParser.getAreaName(areaCode);
    }
	
	@Rest(simpleServiceName = "anonymity", type = "free")
	public AddressCode getAddressCode(String areaCode) {
		return AreaParser.getAddressCode(areaCode);
    }
	
	public static String getParentCityName(String currentCityCode){
		String parentCityName = null;
		if (currentCityCode.indexOf("_") > 0) {
			int lastIndex = currentCityCode.lastIndexOf("_");
			String parentCode = currentCityCode.substring(0, lastIndex);
			parentCityName = AreaParser.getAreaName(parentCode);
		}
		return parentCityName;
	}
}
